package com.example.demo.service.impl;

import com.example.demo.common.wrapper.Page;
import com.example.demo.entity.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.pojo.qo.UserQo;
import com.example.demo.service.BaseService;
import com.example.demo.service.UserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xcy
 * @Desc
 * @date 2021/3/23 22:56
 * @Version v1.0
 */
@Service("userService")
public class UserServiceImpl extends BaseService implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public Page list(UserQo qo) {
        super.startPage(qo);
        List<User> pageList = userMapper.selectAll();
        PageInfo<User> pageInfo = new PageInfo<>(pageList);
        return super.wrap(pageInfo);
    }

    @Override
    public User findOneById(Integer id) {
        return userMapper.findOneById(id);
    }

    @Override
    public void addOne(User user) {
        userMapper.insert(user);
    }

    @Override
    public void deleteOneById(Integer id) {
        userMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void updateById(Integer id) {
        userMapper.updateById(id);
    }

}
